<template>
  <div class="main">
    <el-dialog title="工作成果考核" width="40%" :visible.sync="dialogFormVisible">
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="80px"
        class="demo-ruleForm"
      >
        <el-form-item label="考核得分" prop="scoreValue">
          <el-select
          v-model="ruleForm.scoreValue"
          placeholder="请选择得分"
          style="width:50%;"
          >
            <el-option value="100">100</el-option>
            <el-option value="95">95</el-option>
            <el-option value="90">90</el-option>
            <el-option value="85">85</el-option>
            <el-option value="80">80</el-option>
            <el-option value="75">75</el-option>
            <el-option value="70">70</el-option>
            <el-option value="65">65</el-option>
            <el-option value="60">60</el-option>
        </el-select>
        </el-form-item>  
        <el-form-item label="备注信息" prop="processNotes">
          <el-input
            type="textarea"
            v-model="ruleForm.processNotes"
            maxlength="200"
            rows="3"
            show-word-limit
          ></el-input>
        </el-form-item>
        <!-- -->
        <!-- <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')"
            >立即创建</el-button
          >
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeForm">取 消</el-button>
        <el-button type="primary" @click="submitForm('ruleForm')"
          >确定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { evaluateWork } from "@/api/system/work";
export default {
  name: "addform",
  data() {
    return {
      dialogFormVisible: false,
      formLabelWidth: "120px",
      ruleForm: {},
      rules: {
        scoreValue: [
          { required: true, message: "请选择考核得分率", trigger: "blur" },
        ],
      },
    };
  },
  created() {
  },
  methods: {
    showdate(value) {
      // console.log(value);
    },
    open() {
      this.dialogFormVisible = true;
    },
    closeForm() {
      this.resetForm("ruleForm");
      this.dialogFormVisible = false;
    },
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          
          evaluateWork(this.ruleForm)
            .then(res => {
              // console.log(res);
              if (res.code == 200) {
                this.resetForm(formName);
                this.dialogFormVisible = false;
                this.$parent.init();
              }
            })
            .catch(error => {
              //  if (res.code == 500) {
              // this.ruleForm.manHour = this.ruleForm.temp;
              // this.$message.warning("工时还原为" + this.ruleForm.temp);
              // console.log("temphour", this.ruleForm.temp);
              // }
              // console.log(error);
            });
            
        } else {
          // console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  }
};
</script>

<style scoped lang="scss">
.tip{
  font-size: 12px;
    color: #606266;
    margin-top: 7px;
}
</style>
